package com.chinasoft.mall.activity;

import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;

import com.chinasoft.mall.R;
import com.chinasoft.mall.activity.adapter.StaffGoodsListAdapter;
import com.chinasoft.mall.framework.Config;
import com.chinasoft.mall.model.BaseBean;
import com.chinasoft.mall.model.response.EmployeeGoodsByClass;
import com.chinasoft.mall.model.response.TopicBean;
import com.chinasoft.mall.widget.LoadListView;
import com.chinasoft.mall.widget.LoadListView.OnRefreshListener;

/**
 * 员工商城话题列表
 * @author Administrator
 *
 */
public class StaffTopGoodsActivity extends BaseActivity implements OnRefreshListener {

	private LoadListView modellist;
	private StaffGoodsListAdapter mlAdapter;
	private List<EmployeeGoodsByClass> gbcb=new ArrayList<EmployeeGoodsByClass>();
	
	private BaseBean bb;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.staff_goods_list);
		initView();
	}
	
	private void initView() {
		gbcb.clear();
		modellist = (LoadListView) findViewById(R.id.modellist);
		mlAdapter = new StaffGoodsListAdapter((MainActivity) this.getParent(),
				null, this.getClass());
		modellist.setAdapter(mlAdapter);
		modellist.setonRefreshListener(this);
	}

	private void initRequest() {
		if (sz != null) {
			if (sz instanceof TopicBean) {
				TopicBean rb = (TopicBean) sz;
					bb= new BaseBean(Config.GET_GOODSBYTPID);
					
					bb.reqData.put("tp_id", rb.getTP_ID());
					control.sendMessage(bb);
				
			}
		}
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public void success(BaseBean obj) {
		super.success(obj);
		if(obj.equals(bb)){
			if(obj.getResData()!=null&&obj.getResData().getData()!=null){
				gbcb.addAll((List<EmployeeGoodsByClass>)obj.getResData().getData());
				mlAdapter.setData(gbcb);
				modellist.onRefreshComplete();
			}
		}
	}

	@Override
	protected void onResume() {
		super.onResume();
		initRequest();
	}

	@Override
	public void onRefresh() {
		// TODO Auto-generated method stub
		
	}

}
